package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.common.article.ArticleConstants;
import com.heima.model.article.dtos.ArticleHomeDTO;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.validator.behavior.ArticleLike;
import com.heima.model.common.validator.behavior.ArticleOperation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "app端文章行为接口",value = "app端文章行为接口")
@RestController
@RequestMapping("/api/v1")
public class BehaviorController {

    @Autowired
    private ApLikesBehaviorService apLikesBehaviorService;
    @ApiOperation(value = "点赞行为",notes = "为自己喜欢的文章的点赞")
    @PostMapping("/likes_behavior")
    public ResponseResult load(@RequestBody  LikesBehaviorDTO dto) {
        return apLikesBehaviorService.like(dto);
    }

    @Autowired
    private ApReadBehaviorService apReadBehaviorService;

    @ApiOperation(value = "阅读行为",notes = "阅读当前文章")
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDTO dto) {
        return apReadBehaviorService.readBehavior(dto);
    }

    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;
    @ApiOperation(value = "不喜欢行为",notes = "不喜欢行为当前文章")
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLikeBehavior(@RequestBody UnLikesBehaviorDTO dto) {
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;
    @ApiOperation(value = "收藏行为",notes = "收藏当前文章")
    @PostMapping("/collection_behavior")
    public ResponseResult collectBehavior(@RequestBody CollectionBehaviorDTO dto) {
        return apCollectionBehaviorService.collectBehavior(dto);
    }

    @Autowired
    ApArticleBehaviorService apArticleBehaviorService;
    @ApiOperation(value = "文章行为",notes = "文章行为")
    @PostMapping("/load_article_behavior")
    public ResponseResult apArticleBehaviorService(@RequestBody ArticleBehaviorDTO dto) {
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }

}
